jQuery(function($) {
	$("#tabs").tabs();
});

if ('ontouchstart' in document.documentElement)
	document.write("<script src='plug-in/ace/js/jquery.mobile.custom.js'>"
			+ "<" + "/script>");

function loadModule(title, url, target) {
	// TODO addTab(title,url);
	if ("工作台" == title) {
		$("#workFrame").attr("src", url);

	} else {
		$("#tabs-main").show();
		$("#mainTitle").text(title);
		$("#center").attr("src", url);
	}
}

function logout() {
	bootbox.confirm("您确定要退出系统吗?", function(result) {
		if (result)
			location.href = "loginController.do?logout";
	});
}
function opendialog(title, url, target) {
	// $("#dialog").attr("src",url);
	bootbox.dialog( {
		message : $("#changestylePanel").html(),
		title : title,
		buttons : {
			OK : {
				label : "确定",
				callback : function() {
					var indexStyle = $('input[name="indexStyle"]:checked')
							.val();
					if (indexStyle == undefined || indexStyle == "") {
						indexStyle = "ace";
					}
					var cssTheme = $('input[name="cssTheme"]:checked').val();
					if (cssTheme == undefined) {
						cssTheme = "";
					}
					var form = $("#formobj");// 取iframe里的form
					$.ajax( {
						url : form.attr('action'),
						type : form.attr('method'),
						data : "indexStyle=" + indexStyle,// +"&cssTheme="+cssTheme,
						success : function(data) {
							var d = $.parseJSON(data);
							if (d.success) {
								var msg = d.msg;
								bootbox.alert(msg);
							} else {
								bootbox.alert(d.msg);
							}
						},
						error : function(e) {
							bootbox.alert("出错了哦");
						}
					});
				}
			},
			Cancel : {
				label : "关闭",
				callback : function() {
					// alert('close');//$("#dialog").dialog("close");
			}
			}
		}
	});

}
function changepass(title, url, target) {
	// $("#dialog").attr("src",url);
	bootbox
			.dialog( {
				message : '<form id="formobj2"  action="userController.do?savenewpwd" name="formobj2" method="post">' + $(
						"#changepassword").html() + '</form>',
				title : title,
				buttons : {
					OK : {
						label : "OK",
						callback : function() {
							// alert('not implement');
						$.ajax( {
							url : "userController.do?savenewpwd",
							type : "post",
							data : $('#formobj2').serialize(),// 要提交的表单 ,
							success : function(data) {
								var d = $.parseJSON(data);
								if (d.success) {
									var msg = d.msg;
									bootbox.alert(msg);
								} else {
									bootbox.alert(d.msg);
								}
							},
							error : function(e) {
								bootbox.alert("出错了哦");
							}
						});
					}
					},
					Cancel : {
						label : "关闭",
						callback : function() {
							// alert('close');//$("#dialog").dialog("close");
					}
					}
				}
			});

}
function profile(title, url, target) {
	// $("#dialog").attr("src",url);
	bootbox
			.dialog( {
				message : '<iframe width="100%" height="300px" src="' + url + '" style="border:1px #fff solid; background:#CCC;"></iframe>',
				title : title,
				buttons : {
					OK : {
						label : "确定"
					},
					Cancel : {
						label : "关闭"
					}
				}
			});

}
function clearLocalstorage() {
	var storage = $.localStorage;
	if (!storage)
		storage = $.cookieStorage;
	storage.removeAll();
	// bootbox.alert( "浏览器缓存清除成功!");
	alertTipTop("浏览器缓存清除成功!", "10%");
}

function goWork(){
	loadModule('我的工作','scheduleController.do?goWork');
	
}